/*
 * @Author: stark
 * @Date: 2022-06-20 15:57:49
 */
const baseUrl = 'http://39.98.112.34:8080/api';

$(function () {
    $.cookie.json = true;
    let userInfo = $.cookie('userInfo') ? $.cookie('userInfo') : null;

    if (userInfo) {
        let html = `<a>${userInfo.nickname}用户，欢迎你</a>
        <a href="javascript:;" class='quit'>[退出]</a>`;
        $(".fl>ul li:eq(1)").html(html);
    } else {
        let html = `
                    <a href="javascript:;" class='login'>请登录</a>
                    <a href="register.html" class="style-red regis">免费注册</a>`
        $(".fl>ul li:eq(1)").html(html);
    }

    // $(document).on('click', '.quit', () => {
    //     $.removeCookie('userInfo', { path: '/' });
    //     location.reload();
    // })

    $(document).on('click', '.quit', function () {
        let back = encodeURIComponent(location.href);
        location.href = 'login.html?back=' + back;
    })

    $(document).on('click', '.car-logo', function () {
        location.href = 'index.html'
    })

})

$.getUrlParam = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}







